package com.wanhong.springboot.ssm.framework.context;

import com.wanhong.springboot.ssm.framework.jwt.UserContext;

/**
 * @author w_yu
 * @date 2020/11/26 16:11
 * @desc
 */
public class UserContextHandler {

    private static final ThreadLocal<UserContext> threadLocal = new InheritableThreadLocal<>();

    public static void set(UserContext userContext) {
        if (userContext != null) {
            threadLocal.set(userContext);
        }
    }

    public static UserContext get() {
        return threadLocal.get();
    }


    public static void remove() {
        threadLocal.remove();
    }

}
